<include file="../Public/header.html" />

<link href="__PUBLIC__/Css/goodDetail.css" rel="stylesheet" type="text/css">

<link href="__PUBLIC__/Js/jTip/css/global.css" rel="stylesheet" type="text/css">

<script src="__PUBLIC__/Js/jTip/js/jtip.js" type="text/javascript"></script>

<style>
.receiverlist table th {
    background-color: #F2F4F6;
    border-bottom: 1px solid #C1C8D2;
    color: #151515;
    font-weight: bold;
    height: 30px;
    padding-left: 5px;
    padding-right: 5px;
    text-align: left;
}
.receiverlist table th.line_l {
    background: url("/Public/Images/global/th_bg.gif") repeat-y scroll 0 0 #F2F4F6;
}
.receiverlist table td {
    border-bottom: 1px solid #E3E6EB;
    border-left: 1px solid #E3E6EB;
    padding: 5px 5px;
	line-height: 18px;
}
.receiverlist .bg_hover {
    background-color:#F3F3F3;
}

</style>

<script type="text/javascript">
    //鼠标移动表格效果
    $(document).ready(function(){
    	inittable();
    });
    
    function inittable(){
        $("#receiver_list_table").find('tr').hover(
          function () {
            $(this).addClass("bg_hover");
          },
          function () {
            $(this).removeClass("bg_hover");
          }
        );
    }

</script>

<!--页面主部-->
<div id="main"> 
	<!--头部现在位置-->
	<php>	$TOP_NAV_BOX_PARAM[]=array('url'=>U('Product://Index/searchp'),'desc'=>$_ARY_HRADER_NAV_DICT['GIFT']);
			$TOP_NAV_BOX_PARAM[]=array('desc'=>'确认订单');
	</php>
	<include file="../Public/top_nav_box.html" />
	
	<div class="left_box o_step_box">
		<include file="../Product/Tpl/default/Public/order_step_box.html" />
		<div class="clear"></div>
	</div>
	<!--主体左部，为商品详情页-->
	<div class="right_box">
			<div id="payment">

			    <!--第一步，确认最终发送的彩信信息内容-->
				<div class="step" style=" padding: 0px;">
			        <div class="cont" style="padding-top: 0px;">
			        	<!-- 
		        		<span style="float:right;margin-top: 5px;">请确认最终发送的彩信内容！</span>
    		       		<h2 class="subStep">确认发送内容</h2>
		        		-->
						<div class="panel_style2" >
							<div class="mmsWrapper">
								<php>
									//数据格式：
									$tmp_mms_sample_data['send_format'] = $order_data['sender']['send_format'];//发送类型 sms或mms。
									$tmp_mms_sample_data['mms_bg']=getAttachUrl(getMmsBg($order_data['shelf']['shelf_id']));//发送的mms背景图片路径getAttachUrl(getMmsBg($order_data['shelf']['shelf_id']))}
									$tmp_mms_sample_data['mms_card']=U('Product://Order/getSmsImg',array('rand'=>time()));//发送的mms对应的贺卡路径U('Product://Order/getSmsImg',array('rand'=>time()))}
									
									$tmp_mms_sample_data['tplt_data']['{sender_name}'] 	= $order_data['sender']['sender_name'];//发送者
									$tmp_mms_sample_data['tplt_data']['{sms_message}'] 	= $order_data['txtdata']['txt_content'];//短信发送的文字
									$tmp_mms_sample_data['tplt_data']['{partner_title}']	= $order_data['shelf']['partner_title'];//商户名称
									$tmp_mms_sample_data['tplt_data']['{coupon_passcode}']	= '********';//商品券码
									$tmp_mms_sample_data['tplt_data']['{goods_title}']		= $order_data['shelf']['goods_title'];//商品名称
									$tmp_mms_sample_data['tplt_data']['{goods_quantity}']	= "**";//商品数量
									$tmp_mms_sample_data['tplt_data']['{goods_expired_date}']	= exchangeTimeDesc($order_data['shelf']['shelf_exchange_time'])	;						
								
									$tmp_mms_sample_data['tplt_data']['{goods_ext_info}']	= getMMSExtInfo($order_data['shelf']['goods_get_type'],$order_data['shelf']['partner_phone'],$order_data['shelf']['partner_mobile']);
									$tmp_mms_sample_data['tplt_data'] = assembleMMSData($tmp_mms_sample_data['tplt_data']);
									//dump($tmp_mms_sample_data['tplt_data']);
								</php>
							 	<include file="../Public/mms_sample.html" />
							<div class="paySummary">
							
								<div class="list_info">
									<h2>给您的提示:</h2>
									<div>
								      	<ul>
									      	<php>$_tmp_sysm = K('SP_NOTICE');
												foreach($_tmp_sysm as $_tmp_vo){</php>
												<li>{$_tmp_vo}</li>
											<php>}</php>
								      	</ul>
							    	</div>
								</div>
 							
								<div class="list_info" style="margin-top: 0px;">
									<span style="float:right;margin-top: 11px;">请确认收礼人、数量及发送时间！</span>
									<h2>收礼人信息</h2>
									<div class="list" style=" padding-top: 0px;">
									<table cellspacing="0" cellpadding="0" border="0" width="100%">
										<tbody>
										  <tr rel="order_title">
										  	<th  style="text-align: center;width:7%;">&nbsp;</th>
										    <th class="line_l" style="text-align: center;width:26%;">手机号</th>
										    <th class="line_l" style="text-align: center;width:20%;">姓名</th>
										    <th class="line_l" style="text-align: center;width:12%;">数量</th>
										    <th class="line_l" style="text-align: center;width:35%;">发送时间</th>
										  </tr>
										</tbody>
									</table>
									<table cellspacing="0" cellpadding="0" border="0" width="100%" id="receiver_list_table">
										<tbody>
										  <php>
					                    	$i = 0;
					                    	$notsavemobile='';//保存为保存的电话号码
					                    	foreach($order_data['receivers']['data'] as $data_){
					                    		$i = $i+1;
					                    		if(!empty($mobilenames[$data_[0]])){ $_mobilename = $mobilenames[$data_[0]]; }
					                    		else{ $_mobilename = "-&nbsp;-&nbsp;&nbsp;-&nbsp;-";  if(!in_array($data_[0],$notsavemobile))$notsavemobile[]=$data_[0]; }
					                    	</php>
					                        <tr <php>if($i%2!=1){</php> class="tr_bg" <php>}</php> >
					                            <td style="text-align: center;border-left: 0px;width:7%;">{$i}</td>
					                            <td class="line_l" style="text-align: center;width:26%;">{$data_[0]}</td>
					                            <td class="line_l" style="text-align: center;width:20%;overflow: hidden;" title="{$mobilenames[$data_[0]]}" id="mname{$data_[0]}">
					                            	{$_mobilename}</td>
					                            <td class="line_l" style="text-align: center;width:12%;">{$data_[1]} 个</td>
					                            <td class="line_l" style="text-align: center;width:35%;">
					                            {:formatSendTargetTime(paramDate($data_[2]),$data_[3])}</td>
					                        </tr>
					                       <php>}</php>
					                       <php>
					                    	//$i = 0;
					                    	for(;$i<5;$i++){
					                    	</php>
					                        <tr>
					                            <td style="text-align: center;border-left: 0px;">&nbsp;</td>
					                            <td class="line_l" style="text-align: center;">&nbsp;</td>
					                            <td class="line_l" style="text-align: center;">&nbsp;</td>
					                            <td class="line_l" style="text-align: center;">&nbsp;</td>
					                            <td class="line_l" style="text-align: center;">&nbsp;</td>
					                        </tr>
					                       <php>}</php>
										</tbody>
									</table>
									</div>
								</div>				
								<script type="text/javascript">
									var paytotal = parseFloat( '{$order_data['payment']['pay_money']}' );
			           				$(document).ready(function(){
			           					<php>if(!empty($notsavemobile)){</php>
			           							showAddPbook();
			           					<php>}</php>
			           					$('#cashcoupon_number').bind("keyup",function(){
			           						checkCashCoupon();
			           					});
			           				});
			           				function doAddPBook(){
			           					var data_='';
			           					$("#add_pbook_area").find("tr").each( function(i, tr){
							           						var Jtr = $(tr);
							           						if(Jtr.attr('rel')==null||Jtr.attr('rel')==''||Jtr.attr('rel')=='null')return;
							           						var mobile_ = Jtr.find('#mobile').val();
							           						var name_   = jQuery.trim(Jtr.find('#name').val());
							           						data_ = data_+"-$-"+mobile_+"-!-"+name_;
			           					});
			           					
			           			    	$.kajax({      
			           			    		ajx_rtn_type:'JSON',//HTML JSON
			           			    		url:"{:U('User://Account/doAddPhonebooks')}",      
			           			    		type:'post', //数据发送方式  
			           			    		data:{pbdata:data_} ,    
			           			    		async: false ,//同步方式     
			           			    		success: function(objson){ 
			           			    			//alert(1);
			           			    			if(objson.status==1){
			           			    				$("#add_pbook_area").find("tr").each( function(i, tr){
						           						var Jtr = $(tr);
						           						if(Jtr.attr('rel')==null||Jtr.attr('rel')==''||Jtr.attr('rel')=='null')return;
						           						var mobile_ = Jtr.find('#mobile').val();
						           						var name_   = jQuery.trim(Jtr.find('#name').val());
						           						if(name_!=''){
						           							$("#receiver_list_table").find("#mname"+mobile_).text(name_);
						           						}
		           									});
			           			    			}
			           			    			ui.box.close();
			           			    		}
			           			    	});
			           			    }
	
			           			    function showAddPbook(){
			           			    	html_='<div style="width: auto; height: auto;padding: 15px;" class="do_box" id="add_pbook_area">'
			           							+'<table cellspacing="0" cellpadding="0" border="0" align="center" class="do_list"><tbody>';
			           					html_ = html_	+'<tr><td height="25" style="text-align:left;font-weight: bold;" valign="middle">'
   												+'是否将下列手机号添加到电话薄？</td></tr>';
			           					<php>
			           					foreach($notsavemobile as $vopb){</php>
			           					html_ = html_	+'<tr rel="$vopb"><td height="30" valign="middle">'
           												+'手机号：{$vopb}&nbsp;&nbsp;&nbsp;&nbsp;'
           												+'姓名：<input type="text" class="do_input s_input" value="" style="width: 120px;font-size: 12px; height: 20px; line-height: 20px;" id="name" max="12"/>'
           						        				+'<input type="hidden" value="{$vopb}" id="mobile" /></td></tr>';
			           					<php>}</php>
			           					
			           					html_ = html_	+'</tbody>'
							           					+'</table>'
							           					+'</div>'
							           					+'<div class="answers" style="">'
							           					+'<input type="button" class="btn_ok" onclick="doAddPBook()" value="确定" id="k_confirm_btn">&nbsp;'
							           					+'<input type="button" class="btn_cancel" onclick="ui.box.close()" value="取消" id="k_confirm_btn">'
							           					+'</div>'
							           					
							           					;
					           			ui.box.show(html_,{title:'添加手机号到电话薄'});
			           					/**
			           			    	ui.confirm(obj,
			           			    				"修改姓名：<input type='text' class='do_input s_input' "
			           			    				+ "value='"+$('#pb_name_'+pbid).text()+"'  style='width:100px;height: 20px; font-size: 12px;line-height: 20px;' id='modify_pbook_name' max='12'/>");
			           			   		**/ 				
			           			    }
			           			    
			           			    /** 检查代金券长度（代金券长度必须为16位） **/
			           			    function checkCashCoupon(){
			           			    	var cashcoupon_number = jQuery.trim($('#cashcoupon_number').val());
			           			    	if(cashcoupon_number.length!=16){ $('#check_cashcoupan_wrong').html('优惠券长度为16位！');return 0;}
			           			    	var cashcoupon_no = 0;
			           			     	$('#check_cashcoupan_wrong').html('稍等，优惠券检查中....');
			           			    	$.kajax({      
		       					    		ajx_rtn_type:'JSON',
		       					    		url:"{:U('Product://Order/ajxCheckCashCoupon')}",      
		       					    		type:'post', //数据发送方式  
		       					    		data:{ccpcode:cashcoupon_number} ,    
		       					    		async: true ,//同步方式     
		       					    		success: function(objson){
		       					    				var result = objson.data;
		       					    				$('#check_cashcoupan_wrong').html(objson.msg)
		    			           			    	if(objson.status==1){
		    			           			    		$('#cashcoupon_no_4show').html(result['amount']);
		    			           			    		cashcoupon_no = parseFloat( result['amount'] );
		    			           			    	}
		       					    				//alert(result);
			       					    		}
		       					    	});
			           			    	//alert(1+cashcoupon_no);
			           			    	//return cashcoupon_no;
			           			    }
			           			 	function useCashCoupon(){
			           			 		
				           			 	var cashcoupon_number = jQuery.trim($('#cashcoupon_number').val());
			           			    	if(cashcoupon_number.length!=16){ $('#check_cashcoupan_wrong').html('优惠券长度为16位！');return 0;}
			           			    	
			           			    	$.kajax({      
		       					    		ajx_rtn_type:'JSON',
		       					    		url:"{:U('Product://Order/ajxUseCashCoupon')}",      
		       					    		type:'post', //数据发送方式  
		       					    		data:{ccpcode:cashcoupon_number} ,    
		       					    		async: true ,//同步方式     
		       					    		success: function(objson){
		       					    				var result = objson.data;
		       					    				$('#check_cashcoupan_wrong').html(objson.msg);
		    			           			    	if(objson.status==1){
		    			           			    		var cashcoupon_no = result['amount'];
		    				           			 		if(cashcoupon_no>0){
		    				           			 			$('#cashcoupon_no').html( parseFloat(cashcoupon_no).toFixed(2) );
		    				           			 			$('#cashcoupon_code').html($('#cashcoupon_number').val());
		    				           			 			$('#cashcoupon_no_used').html( parseFloat(cashcoupon_no).toFixed(2) );
		    				           			 			if(paytotal-cashcoupon_no>0){
		    				           			 				$('#count_total').html( parseFloat(paytotal-cashcoupon_no).toFixed(2) );
		    				           			 			}else{
		    				           			 			$('#count_total').html( parseFloat(0).toFixed(2) );
		    				           			 			}
		    				           			 			k_changeGroupStyle('cashcoupon_opt','p','used','show');
		    				           			 			//k_changeGroupStyle('cashcoupon_opt','p','used','show');
		    				           			 		}
		    			           			    	}
			       					    		}
		       					    	});
			           			 	}
			           			 	function cancelCashCoupon(){
				           			 	$.kajax({      
		       					    		ajx_rtn_type:'JSON',
		       					    		url:"{:U('Product://Order/ajxCancelCashCoupon')}",      
		       					    		type:'post', //数据发送方式  
		       					    		data:{} ,    
		       					    		async: true ,//同步方式     
		       					    		success: function(objson){
		       					    				var result = objson.data;
		       					    				$('#check_cashcoupan_wrong').html(objson.msg);
		    			           			    	if(objson.status==1){
		    			           			    		$('#cashcoupon_no').html( parseFloat(0).toFixed(2) );
		    				           			 		$('#cashcoupon_no_4show').html(0);
		    				           			 		$('#check_cashcoupan_wrong').html('');
		    				           			 		$('#cashcoupon_code').html('');
		    				           			 		$('#cashcoupon_no_used').html(0);
		    				           			 		$('#count_total').html(parseFloat(paytotal).toFixed(2));
		    				           			 		k_changeGroupStyle('cashcoupon_opt','p','select','show');
		    			           			    	}
			       					    		}
		       					    	});
			           			 	}
		           				</script>
		           				<div class="list_info" style="margin-top: 10px;">
		           					<span style="float:right;margin-top: 11px;">请确认账单！</span>
									<h2>账单详情</h2>
									<div class="panel_style2">
								   		<div style="text-align:left;padding:0px 5px;">
								   			<div style="height:30px" class="clightgray" id="cashcoupon_opt">
								   			<p rel="select" class="hidden show">
											  	如您有优惠券，请点击&nbsp;
											  	<a href="javascript:void(0);" onclick="k_changeGroupStyle('cashcoupon_opt','p','input','show');" 
											  		style="text-decoration:underline;color: #008CD6;" >输入优惠券号码</a>
											  	<a href="#?width=250" class="jTip" id="tip_one" rel='jtip_cashcoupon' name="优惠券使用说明：">
											  		<img alt="优惠券使用帮助" src="/Public/Images/global/icon_help.gif">
											  	</a>
											</p>
											
											<p class="hidden" rel="input">
												优惠券号：
												<input type="text" maxlength="16" id="cashcoupon_number" style="width:105px;margin-top: -4px;border: 1px solid #999999;height: 14px;padding: 3px 2px;border-color: rgb(0, 140, 214); color: rgb(0, 140, 214);">
												<span class="cblue" style="font-weight: 700;margin: 0 10px 0 5px;">-<font id="cashcoupon_no_4show">0</font>元</span>
											  	<span class="privbutton" title="点击确认使用！" 
											  		onclick="useCashCoupon();">使用</span>
											  	<span class="privbutton" onclick="k_changeGroupStyle('cashcoupon_opt','p','select','show');">取消</span>
												<span class="cred" id="check_cashcoupan_wrong" style="margin: 0 0px 0 5px;"></span>
											</p>
											
											<p class="hidden" rel="used">
												使用优惠券（<font class="cblue" id="cashcoupon_code"></font>），抵扣<font class="cblue">-<font id="cashcoupon_no_used">0</font>元</font>。
											  	<span class="privbutton_ok" onclick="cancelCashCoupon();">取消使用</span>
											</p>
											</div>
									   		<p style="font-weight:bold;font-size: 14px;">
											<span style="margin: 0 20px 0 0;">商品单价：<font class="cred fb">{:formatMoney($order_data['payment']['out_price'])}</font></span>
											<span style="margin: 0 20px 0 0;">购买数量：<font class="cred fb">{$order_data['payment']['total_no']} 件</font></span>
											<span style="margin: 0 10px 0 0;">优惠券抵扣：<font class="cblue fb">-<font id="cashcoupon_no">0.00</font>元</font></span>
											</p>
										</div>
										<div style="border-top: 1px solid #C4C2C2;margin: 10px 0px;	padding: 10px 0 0;text-align: right;">
											<span style='color: #CC0000;font-size: 15px;font-weight: bold;'>总计：需支付&nbsp;&nbsp;
											<font id='count_total' style="font-size: 22px;color: #FF0000;font-weight: normal;">{$order_data['payment']['pay_money']}</font>&nbsp;&nbsp;元
											</span>
										</div>
									</div>
								</div>

		           			</div>
		           		</div>
			         </div>
				  </div>
				</div>
				
				<style>
				.privbutton_ok {
				    background: url("/Public/Images/global/privbutton_ok.gif") no-repeat scroll 0 0 transparent;
				    color: #FFFFFF;
				    cursor: pointer;
				    height: 19px;
				    line-height: 19px;
				    margin: 0 5px 0 0;
				    padding: 1px 11px;
				    width: 39px;
				}
				.privbutton {
				    background: url("/Public/Images/global/privbutton.gif") no-repeat scroll 0 0 transparent;
				    color: #FFFFFF;
				    cursor: pointer;
				    height: 19px;
				    line-height: 19px;
				    padding: 1px 8px;
				    width: 39px;
				}
				</style>
				
			<!--第三步，支付 style="vertical-align: top;padding-top:5px"-->
			<div class="step" >
				    <div class="cont" style="padding: 0px 0px 15px 0px;">
				    
				    <!--	
				    <span style="float:right;margin-top: 5px;">请选择支付方式！</span>
				     -->
				  	<h2 class="subStep">选择支付方式</h2>
						
						<div id="paytypeselect" style="text-align:left;padding:0px;">
								<ul class="paytype-list " id="order-check-typelist">
									
									<li class="item">
										<div class="bank" style="width:100%">
										<input type="radio"	value="tenpay" name="payType" id="payType" class="input" >
										<img src="/Public/Images/global/tenpay_icon.gif" style="margin-top:3px;">
										<label class="label" style="margin-top:10px;margin-left:20px;">无需注册，支持国内各大银行支付</label>
										</div>
									</li>
									<li class="item">
										<div class="bank" style="width:100%">
										<input type="radio"	value="alipay" name="payType" id="payType" class="input" >
										<img src="/Public/Images/global/alipay_icon.gif" style="margin-top:3px;">
										<label class="label" style="margin-top:10px;margin-left:20px;">推荐淘宝用户使用</label>
										</div>
									</li>
									
									<li class="item">
										<php>
											$tmp_ary_paymentconfig = (include K_CONFIG_PATH.'config_payment.php');
											//dump($tmp_ary_paymentconfig);
											$tmp_index = 0;
											foreach($tmp_ary_paymentconfig['pay_bank'] as $payconf){
												if(in_array($payconf['code'],array('xxypay','alipay','tenpay')))continue;
												</php>
													<div class="bank">
													<input type="radio"	value="{$payconf['code']}" name="payType" id="payType" class="input" >
															<img src="{$payconf['icon']}">
													</div>
												<php>
												$tmp_index = $tmp_index+1;
												if($tmp_index%4==0){
												</php>
													</li><li class="item">
												<php>}
											}
										</php>
									</li>
									
								</ul>
								
								<div class="clear"></div>
								<input type="hidden" value="yes" name="submit">
						
								<div class="step" style="text-align:right;margin: 0 10px;">
									<input type="button" onclick="history.back();" class="btn_r" value="返回修改" />
									&nbsp;&nbsp;&nbsp;
					  				<input type="button" onclick="doconfirm();" class="btn_r" value="确认订单" />
					  				<script type="text/javascript">
					  				//$notsavemobile
					  				function doconfirm(){
					  					paytype_ = '';
					  					$("#order-check-typelist").find("#payType").each(function(){
					  					   if($(this).attr("checked")==true){
					  						 paytype_ = $(this).attr("value");
					  					   }
					  					});
					  					if(paytype_==''){
					  						k_alert('请选择支付类型','提示');
					  						return;
					  					}

					  					k_loading('订单处理中，请稍候...','提交订单');
					  					$.kajax({    
					  						ajx_rtn_type:'JSON',
					  					    url:"{:U('Product://Order/doConfirm')}",      
					  					    type:'post', //数据发送方式  
					  					    data:{submit:'yes'} ,   
					  					    //dataType:'xml', //接受数据格式      
					  					    error:function(json){     
					  					            // alert( "not lived!");     
					  					       },     
					  					    async: false ,//同步方式     
					  					    success: function(obj){ 
					  					    	if(obj.status==1){
					  					    		//alert("/order_id/"+obj.order_id+"/paytype/"+paytype_);
					  					    		//k_page_redirect("{:U('Product://Order/detail')}"+"/order_id/"+obj.order_id+"/paytype/"+paytype_);
					  					    		//k_page_redirect("{:U('User://Index/sendList')}"+"/order_id/"+obj.order_id+"/paytype/"+paytype_);
					  					    		k_page_redirect("{:U('Product://Order/doPay')}"+"/order_id/"+obj.order_id+"/paytype/"+paytype_);
					  					    	
					  					    	}else{
					  					    		k_alert(obj.msg,'提交订单失败');
					  					    	}
					  					    } 
					  	  				});

					  				}
					  				</script>
								</div>
						</div>
					
				</div>
			</div>

		</div>
	</div>

</div>


<!-- 提示信息 每种提示以div保存 通过id 和 处罚提示标签的rel来对应-->
<div id="jTip_info_area" class="hidden">
	<div id="jtip_cashcoupon">
		<div style="line-height:25px">
			 <span>录入您收到的优惠券号码。点击“使用”，即可抵扣对应金额的现金。</span>
			 <br>
			 <span>当优惠券金额大于订单总金额时，代金券多出金额自动作废。</span>
		</div>
	</div>
</div>
<include file="../Public/footer.html" />